<template>
  <a-layout-header class="btn-bar">
    <slot></slot>
    <!-- <a-button type="link" size="small" @click="emit('uploadJson')">
      <template #icon>
        <SvgIcon name="upload" prefix="icon-form" color="#0177FD" size="14" />
      </template>
      导入JSON
    </a-button>
    <a-button type="link" size="small" @click="emit('clearable')">
      <template #icon>
        <SvgIcon name="clearable" prefix="icon-form" color="#0177FD" size="14" />
      </template>
      清空
    </a-button> -->
    <!-- <a-button type="link" size="small" @click="emit('preview')">
      <template #icon>
        <SvgIcon name="preview" prefix="icon-form" color="#0177FD" size="14" />
      </template>
      预览
    </a-button> -->
    <!-- <a-button type="link" size="small" @click="emit('generateJson')">
      <template #icon>
        <SvgIcon name="generate-json" prefix="icon-form" color="#0177FD" size="14" />
      </template>
      生成JSON
    </a-button>
    <a-button type="link" size="small" @click="emit('generateCode')">
      <template #icon>
        <SvgIcon name="generate-code" prefix="icon-form" color="#0177FD" size="14" />
      </template>
      生成代码
    </a-button> -->
    <template v-if="props.onlySubmit">
      <a-button v-if="!props.isModal" type="link" size="small" @click="emit('submit', 1)">
        <template #icon>
          <SvgIcon name="generate-code" prefix="icon-form" color="#0177FD" size="14" />
        </template>
        提交
      </a-button>
    </template>
    <template v-else>
      <a-button type="link" size="small" @click="emit('submit', 0)">
        <template #icon>
          <SvgIcon name="generate-code" prefix="icon-form" color="#0177FD" size="14" />
        </template>
        暂存
      </a-button>
      <a-button type="link" size="small" @click="emit('submit', 1)">
        <template #icon>
          <SvgIcon name="generate-code" prefix="icon-form" color="#0177FD" size="14" />
        </template>
        提交并启用
      </a-button>
    </template>
  </a-layout-header>
</template>

<script lang="ts" setup>
// export default defineComponent({
//   name: 'AntdHeader',
//   emits: ['uploadJson', 'clearable', 'preview', 'generateJson', 'generateCode']
// })

const props = defineProps<{
  onlySubmit: boolean
  isModal: boolean
}>()

const emit = defineEmits(['uploadJson', 'clearable', 'preview', 'generateJson', 'generateCode', 'submit'])
</script>
